<?php
/**
 * 简单分页类
 *
 * @author iwind <iwind.iwind@gmail.com>
 * @link http://www.4kiki.net/
 * @version $Id: ISimplePager.php 312 2008-04-23 16:29:38Z iwind $
 * @package net.4kiki.pager
 */

/**
 * 简单分页类
 * 
 * 下面是一个简单的例子
 * <code>
 * import("net.4kiki.pager.*");
 * $pager = new ISimplePager();
 * $pager->setContentSize(100);
 * $pager->setPageSize(21);
 * $pager->setKeyword("pager");
 * $pager->setPath("pager.php");
 * $pager->setQuery("a=b&pager=%{PAGE_NO}&d=1");
 * echo $pager;
 * echo "startOffset:" . $pager->getStartOffset();
 * </code>
 * 
 * @version $Id: ISimplePager.php 312 2008-04-23 16:29:38Z iwind $
 * @package net.4kiki.pager
 */
class ISimplePager extends IAbstractPager {
	public function __toString() {
    	$page = array();
        $page["input"] = "输入页数 <input type=\"text\" name=\"pageno\" onblur=\"window.location='" . $this->getPath() . "?" . $this->getQuery() .  "'.replace('" . IPager::PAGER_VARIABLE_STRING . "',this.value);\" size=\"3\" maxlength=\"10\" />  ";
        $page["no"] = "第 " . $this->getCurrentPageNo() . " 页, 共 " . $this->getPageNumber() . " 页 |  ";
        $page["first"] = ($this->getPageNumber() > 0) ? "<a href=\"" . $this->getURL(1) . "\" target=\"_self\">首页</a>  ":"首页  ";
        $page["pre"] = ($this->getCurrentPageNo() > 1)? "| <a href=\"" . $this->getURL($this->getCurrentPageNo() - 1) . "\" target=\"_self\">上一页</a> ":"| 上一页 ";
        $page["next"] = ($this->getCurrentPageNo() <= $this->getPageNumber() - 1)?"| <a href=\"" . $this->getURL($this->getCurrentPageNo() + 1) . "\" target=\"_self\">下一页</a> ":"| 下一页 ";
        $page["last"] = ($this->getPageNumber() > 0)?"| <a href=\"" . $this->getURL($this->getPageNumber()) . "\" target=\"_self\">尾页</a>":"| 尾页";

        //构造页码显示
        $string = implode("", $page);
        
        return $string;
	}
}

?>